package com.s3u4.demo.zookeeper.threads;

import java.util.concurrent.CountDownLatch;

/**
 * Created by Captain on 18/10/2017.
 */
public class ThredClient {

    public static int index = 0;

    public static void main(String[] args) throws InterruptedException {
        int threadSize = 500;
        CountDownLatch countDownLatch = new CountDownLatch(1);
        for (int i = 0 ; i < threadSize ; i++){
            new Thread( () -> {
                try {
                    countDownLatch.await();
                    System.out.println("Current Index : " + index++);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();
        }

        Thread.sleep(2000);
        countDownLatch.countDown();


        Thread.sleep(5000);
        System.out.println(index);
    }


}
